﻿/*
 * You are given a sequence of positive integer values written into a string, separated by spaces. 
 * Write a function that reads these values from given string and calculates their sum.
 * */
using System;

class IntegerSequence
{
    static void Main(string[] args)
    {
        Console.WriteLine("Enter positive integers on a single line, separated by space:");

        string inputLine = Console.ReadLine();

        long sum = CalculateIntegerSequenceSum(inputLine);

        Console.WriteLine("The sum of the integers in the line is: {0}", sum);
    }

    private static long CalculateIntegerSequenceSum(string inputLine)
    {
        char[] delimeters = {' '};

        string[] strNumbers = inputLine.Split(delimeters, StringSplitOptions.RemoveEmptyEntries);

        long sum = 0;

        for (int i = 0; i < strNumbers.Length; i++)
        {
            sum += int.Parse(strNumbers[i]);
        }

        return sum;
    }
}

